import axios, { AxiosResponse } from "axios";

import { ErrorCode } from "./httpError";
// import { message } from 'antd';
// const URL = '/api'

const request = axios.create({
    baseURL: '',
    timeout: 30000
})

request.interceptors.request.use(config => {
    return config
}, error => {
    return Promise.reject(error)
})

request.interceptors.response.use((response: AxiosResponse<any, any>) => {
    if (response.status === 200) {
        return response.data
    }
}, (error) => {
    console.log('%c [ error ]-22', 'font-size:13px; background:pink; color:#bf2c9f;', ErrorCode(error.response.status))
    // message.error(ErrorCode(error.response.status))
    return Promise.reject(error)
})


export default request